package zzs.generalframework.util.core.reflect;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

/**
 * @title
 * @description
 * @project zzs-util
 * @package zzs.generalframework.util.core.reflect
 * @author zzs
 * @date 2018年1月30日
 * @version 1.0
 */
public class ClassUtils
{

	/**
	 * 获取类中所有字段的name-type映射集合
	 * 
	 * @param clazz
	 * @return
	 */
	public static Map<String, String> getFieldTypeMap(Class<? extends Object> clazz)
	{
		Map<String, String> returnMap = null;
		Field[] fieldArray = clazz.getDeclaredFields();
		if (fieldArray.length > 0)
		{
			returnMap = new HashMap<String, String>();
			for (Field itemField : fieldArray)
			{
				String fieldName = itemField.getName();
				String fieldType = itemField.getType().toString();
				returnMap.put(fieldName, fieldType);
			}
		}
		return returnMap;
	}

}
